package user

import (
	"context"
	"fmt"
)

const (
	AppName = "users"
)

type Service interface {
	// 用户的创建
	CreateUser(context.Context, *CreateUserRequest) (*User, error)
	// 查询用户详情
	DescribeUser(context.Context, *DescribeUserRequest) (*User, error)
	// 用户登录接口
	Login(context.Context, *LoginRequest) (*Token, error)
	// 校验用户Token
	ValiateToken(context.Context, *ValiateTokenRequest) (*Token, error)
}

func NewLoginRequest() *LoginRequest {
	return &LoginRequest{
		CreateUserRequest: NewCreateUserRequest(),
	}
}

type LoginRequest struct {
	*CreateUserRequest
}

func NewValiateTokenRequest(ak string) *ValiateTokenRequest {
	return &ValiateTokenRequest{
		AccessToken: ak,
	}
}

type ValiateTokenRequest struct {
	AccessToken string
}

func NewDescribeUserRequestByName(name string) *DescribeUserRequest {
	return &DescribeUserRequest{
		DescribeBy:    DESCRIBE_BY_NAME,
		DescribeValue: name,
	}
}

func NewDescribeUserRequestById(uid int) *DescribeUserRequest {
	return &DescribeUserRequest{
		DescribeBy:    DESCRIBE_BY_ID,
		DescribeValue: fmt.Sprintf("%d", uid),
	}
}

type DescribeUserRequest struct {
	DescribeBy    DESCRIBE_BY
	DescribeValue string
}
